using System;
using System.Collections.Generic;
using System.Text;
using Rss;
using System.Collections;
using System.ComponentModel;

namespace LWRSSReader
{


	[Serializable]
	public class RssFeedWrapCollection : CollectionBase, ICustomTypeDescriptor
	{


		public RssFeedWrap this[string url]
		{
			get
			{
				for (int i = 0; i < List.Count; i++)
				{
					if (((RssFeedWrap)List[i]).Url == url)
					{
						return this[i];
					}
				}
				return null;
			}
		}



		#region RssFeedCollection almost copy-paste
		public RssFeedWrap this[int index]
		{
			get
			{
				if (index < List.Count)
					return ((RssFeedWrap)(List[index]));
				return null;

			}
			set { List[index] = value; }
		}



		public int Add(RssFeedWrap feed)
		{
			return List.Add(feed);
		}
		public bool Contains(RssFeedWrap RssFeedWrap)
		{
			return List.Contains(RssFeedWrap);
		}
		public void CopyTo(RssFeedWrap[] array, int index)
		{
			List.CopyTo(array, index);
		}

		public int IndexOf(RssFeedWrap RssFeedWrap)
		{
			return List.IndexOf(RssFeedWrap);
		}

		public void Insert(int index, RssFeedWrap feed)
		{
			List.Insert(index, feed);
		}

		public void Remove(RssFeedWrap feed)
		{
			List.Remove(feed);
		}


		#endregion


		#region ICustomTypeDescriptor Members

		public String GetClassName()
		{
			return TypeDescriptor.GetClassName(this, true);
		}

		public AttributeCollection GetAttributes()
		{
			return TypeDescriptor.GetAttributes(this, true);
		}

		public String GetComponentName()
		{
			return TypeDescriptor.GetComponentName(this, true);
		}

		public TypeConverter GetConverter()
		{
			return TypeDescriptor.GetConverter(this, true);
		}

		public EventDescriptor GetDefaultEvent()
		{
			return TypeDescriptor.GetDefaultEvent(this, true);
		}

		public PropertyDescriptor GetDefaultProperty()
		{
			return TypeDescriptor.GetDefaultProperty(this, true);
		}

		public object GetEditor(Type editorBaseType)
		{
			return TypeDescriptor.GetEditor(this, editorBaseType, true);
		}

		public EventDescriptorCollection GetEvents(Attribute[] attributes)
		{
			return TypeDescriptor.GetEvents(this, attributes, true);
		}

		public EventDescriptorCollection GetEvents()
		{
			return TypeDescriptor.GetEvents(this, true);
		}

		public object GetPropertyOwner(PropertyDescriptor pd)
		{
			return this;
		}

		public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
		{
			return GetProperties();
		}

		public PropertyDescriptorCollection GetProperties()
		{
			PropertyDescriptorCollection pds = new PropertyDescriptorCollection(null);
			for (int i = 0; i < this.List.Count; i++)
			{
				RssFeedWrapCollectionPropertyDescriptor pd = new RssFeedWrapCollectionPropertyDescriptor(this, i);
				pds.Add(pd);
			}
			return pds;
		}
		#endregion
	}
}
